﻿@{
    ViewBag.Title = "登录";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model Model.ViewModel.LoginUser

<div class="container">
    <div class="row">

        <div class="col-md-7 col-xs-0 col-sm-7">
            <h6></h6>
            <img src="~/Images/login.jpg" class="img-responsive" />
        </div>
        <div class="col-md-5 col-xs-12 col-sm-5">
            <div class="well well-lg bg-success" style="background-color:#f0f5fb; box-shadow: 0px 2px 8px 0px rgba(50,50,50,0.35); ">
                @using (Ajax.BeginForm("Login", "Admin/AdminLogin", new AjaxOptions
    {
        HttpMethod = "Post",
        OnSuccess = "Success",
        LoadingElementId = "Waiting"
    }, new { @class = "form-horizontal", role = "form" }))
                {

                    <div class="form-group">
                        <label for="LoginName" class="col-sm-3 control-label">用户名：</label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(u => u.LoginName, new { Value = "peter", @class = "form-control" })@Html.ValidationMessageFor(u => u.LoginName)
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Pwd" class="col-sm-3 control-label">密码：</label>
                        <div class="col-sm-9">

                            @Html.PasswordFor(u => u.Pwd, new { Value = "123456", @class = "form-control" })@Html.ValidationMessageFor(u => u.Pwd)
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-9">

                            <div class="checkbox">
                                <label>
                                    @Html.CheckBoxFor(u => u.IsAlways) 保存密码
                                </label>
                            </div>

                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-9">
                            @* <button type="submit" class="btn btn-default">登录</button><span id="Waiting">
                                    <img src="~/Images/ajax-loader.gif" />
                                </span>*@
                            <button type="submit" id="myButton" data-loading-text="Loading..." class="btn btn-primary" autocomplete="off">
                                登录
                            </button>
                            <script>
                                $('#myButton').on('click', function () {
                                    var $btn = $(this).button('loading')
                                    // business logic...
                                    $btn.button('reset')
                                })
                            </script>
                        </div>

                    </div>
                }
            </div>
        </div>
    </div>

</div>


<script type="text/javascript">
    function Success(Jsonmsg) {
        $.procAjaxData(Jsonmsg, function () { window.location = Jsonmsg.BackUrl; });

    }

</script>